<?php
ob_start();
###############################################################################################
### kontakt.php ### 22.05.2006 18:48 ##########################################################
### --------------------------------------------------------------------------------------- ###
### This file is for everyone who wants wo write an email forward to the admin of the page. ###
### You fill in a form like in every email program.                                            ###
###############################################################################################
include("header.php");
?>
    <div class="main_box_content">
<?php
if (empty($_GET['action'])) {

    $pattern_telefon="/^[0-9\+]*$/";

    if ($_POST['mitlaeufer']!="sent" || empty($_POST['name']) || $_POST['email']=="Ihre@email.de" || empty($_POST['betreff']) || empty($_POST['nachricht']) || !eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $_POST['email']) || (!empty($_POST['telefon']) && !preg_match($pattern_telefon,$_POST['telefon']))) {

        print "<span style=\"font-weight:bold;\">Nachricht senden</span><br /><br />";
        print "
        <table style=\"width:100%;\" cellspacing=\"0\" cellpadding=\"0\">
            <tr>
                <form action=\"kontakt.php\" method=post>
                <input type='hidden' name='mitlaeufer' value='sent'>
                <td width='30%' align=right><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Ihr Name:&nbsp;&nbsp;</font></td>
                <td width='70%'><input type=text class=send size=40 name=name style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;' value='".$_POST['name']."'></td>
            </tr>";
            if ($_POST['mitlaeufer']=="sent" && empty($_POST['name'])) {
            print"
            <tr>
                <td width='30%'>&nbsp;</td>
                <td width='70%'><font style='font-family: Verdana; font-size:8pt; color:#E60003;'>Name vergessen</font></td>
            </tr>";
            }
            print "
            <tr>
                <td width='30%' align=right><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Ihre Telefonnummer:&nbsp;&nbsp;</font></td>
                <td width='70%'>
                    <input type=text class=send size=5 maxlength=4 name=lvorwahl style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;' value='"; if (empty($_POST['lvorwahl'])) { echo"+49"; } else { echo $_POST['lvorwahl']; } echo"' onKeypress='if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;'> <input type=text class=send size=6 maxlength=6 name=ovorwahl style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;' value='".$_POST['ovorwahl']."' onKeypress='if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;'> <input type=text class=send size=14 maxlength=12 name=nummer style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;' value='".$_POST['nummer']."' onKeypress='if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;'>
                </td>
            </tr>
            <tr>
                <td width='30%'>&nbsp;</td>
                <td width='70%'><input type=text disabled value='Land' size=5 style='background-color:#FFFFFF; font-family: Verdana; font-size:8pt; color:#184D9E; border:0px;'> <input type=text disabled value='Vorwahl' size=6 style='background-color:#FFFFFF; font-family: Verdana; font-size:8pt; color:#184D9E; border:0px;'> <input type=text disabled  value='Anschluss' size=8 style='background-color:#FFFFFF; font-family: Verdana; font-size:8pt; color:#184D9E; border:0px;'></td>
            </tr>
            <tr>
                <td width='30%' align=right><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Email-Adresse:&nbsp;&nbsp;</font></td>
                <td width='70%'><input type=text size=40 name=email style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;' class=send onFocus=\"if (value == 'Ihre@email.de') {value =''}\" onBlur=\"if (value == '') {value = 'Ihre@email.de'}\" value='";if (empty($_POST['email'])) { echo"Ihre@email.de"; } else { echo $_POST['email']; } echo"'></td>
            </tr>";
            if ($_POST['mitlaeufer']=="sent" && ($_POST['email']=="Ihre@email.de" || !eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $_POST['email']))) {
            print"
            <tr>
                <td width='30%'>&nbsp;</td>
                <td width='70%'><font style='font-family: Verdana; font-size:8pt; color:#E60003;'>Korrekte Email angeben</font></td>
            </tr>";
            }
            print "
            <tr>
                <td width='30%' align=right><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Betreff:</font>&nbsp;&nbsp;</td>
                <td width='70%'><input type=text class=send style=width:90% name=betreff style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;' value='".$_POST['betreff']."'></td>
            </tr>";
            if ($_POST['mitlaeufer']=="sent" && empty($_POST['betreff'])) {
            print "
            <tr>
                <td width='30%'>&nbsp;</td>
                <td width='70%'><font style='font-family: Verdana; font-size:8pt; color:#E60003;'>Betreff vergessen</font></td>
            </tr>";
            }
            print "
            <tr>
                <td width='30%' align=right valign=top><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Nachricht:&nbsp;&nbsp;</td>
                <td width='70%' ><textarea style=width:90% rows=10 class=send name=nachricht style='font-family: Verdana; font-size:8pt; color:#184D9E; border: 1px solid #184D9E;'>".$_POST['nachricht']."</textarea><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>"; if ($_POST['mitlaeufer']=="sent" && empty($_POST['nachricht'])) { echo"<br><font style='font-family: Verdana; font-size:8pt; color:#E60003;'>Nachricht eingeben</font><br>"; } echo"<br>(Zeichen unbegrenzt)</font><br><br></td>
            </tr>
            <tr>
                <td width='30%'>&nbsp;</td>
                <td width='70%'><input type=submit class=submit value=Abschicken onmouseover=\"this.style.cursor='hand';\"> <input type=reset class=submit value=Zur�cksetzen onmouseover=\"this.style.cursor='hand';\"></td>
                </form>
            </tr>
        </table>";

    }

    if ($_POST['mitlaeufer']=="sent" && !empty($_POST['name']) && $_POST['email']!="Ihre@email.de" && !empty($_POST['betreff']) && !empty($_POST['nachricht']) && eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $_POST['email'])) {

        $host = $_SERVER['REMOTE_ADDR'];
        $nachricht = nl2br($_POST['nachricht']);
        $nachricht = str_replace("<br />","\n",$nachricht);

        mail("" . $contact_email . "", "" . $_POST['betreff'] . "", "" . $nachricht . "


" . $_POST['name'] . "
" . $_POST['email'] . "
" . $_POST['lvorwahl'] . " " . $_POST['ovorwahl'] . " " . $_POST['nummer'] . "

IP: " . $host . "", "From: " . $_POST['email'] . "");

        print "<span style=\"font-weight:bold;\">Nachricht gesendet</span><br /><br />";
        print "
        <table style=\"width:100%;padding:5px\" cellspacing=\"0\" cellpadding=\"0\">
            <tr>
                <td width='100%'><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Ihre Nachricht wurde erfolgreich gesendet. Wir melden uns innerhalb von 24 Stunden bei Ihnen!</font></td>
            </tr>
            <tr>
                <td width='100%'><br><br><a href='index.php"; if (!isset($_SESSION['sesuser'])) { echo"?referer=".$_GET['referer'].""; } echo"'><font style='font-family: Verdana; font-size:8pt; color:#184D9E;'>Hier geht es zur�ck zur Startseite</font></a></td>
            </tr>
        </table>";

    }
}

?>

    </div>

<?php

include("footer.php");
ob_end_flush();
?>